<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>业务活动模型管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			
			var status  = '${activityConfig.status}';
			status = (status!="1") ? "0" :"1";
			$("input[type='radio'][name='status'][value='"+status+"']").attr("checked", "checked");
			
			$("#lottery").find("option[value='${activityConfig.lottery.id}']").attr("selected",true);
			$("#memberType").find("option[value='${activityConfig.memberType}']").attr("selected",true);
			$("#terminal").find("option[value='${activityConfig.terminal.id}']").attr("selected",true);
			$("#validDays").find("option[value='${activityConfig.validDays}']").attr("selected",true);
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/wechat/activity/activityConfig/">业务活动模型列表</a></li>
		<li class="active"><a href="${ctx}/wechat/activity/activityConfig/form?id=${activityConfig.id}">业务活动模型<shiro:hasPermission name="wechat:activity:activityConfig:edit">${not empty activityConfig.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="wechat:activity:activityConfig:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="activityConfig" action="${ctx}/wechat/activity/activityConfig/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="11" class="required"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">活动时间:</label>
			<div class="controls">
					<script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
					自<input id="createTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
						value="<fmt:formatDate value="${activityConfig.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>  
						至<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
						value="<fmt:formatDate value="${activityConfig.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">人群种类:</label>
			<div class="controls">
				<select id="memberType" class="form-control" name="memberType">
				  <option value="0">普通会员</option>
				  <option value="1">金卡会员</option>
				  <option value="2">VIP会员</option>
				</select>
			</div>
		</div>
		
		<!-- 
		<div class="control-group">
			<label class="control-label">微信分组:</label>
			<div class="controls">
				<select class="form-control" name="groupName">
				<c:forEach items="${groupNameList}" var="groupName" >
				  <option value="${groupName.id }">${groupName.name }</option>
				</c:forEach>
				</select>
			</div>
		</div>
		 -->
		 
		<div class="control-group">
			<label class="control-label">终端设备:</label>
			<div class="controls">
				<select id="terminal" class="form-control" name="terminal.id">
				<option value="0">全部</option>
				<c:forEach items="${terminalList}" var="terminal" >
				  <option value="${terminal.id }">${terminal.name }</option>
				</c:forEach>
				</select>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">活动处理器配置:</label>
			<div class="controls">
				<form:input path="activityProcessor" htmlEscape="false"  class="required"/><span class="alert">添加活动处理类名</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">奖励积分:</label>
			<div class="controls">
				<form:input path="score" htmlEscape="false" maxlength="11" class="required digits" /><span class="alert">活动奖励的积分</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">奖励储值:</label>
			<div class="controls">
				<form:input path="money" htmlEscape="false" maxlength="11" class="required digits"  /><span class="alert">活动奖励金钱如</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">选择奖品:</label>
			<div class="controls">
				<select id="lottery" class="form-control" name="lottery.id">
					 <option value="0">无奖品</option>
				<c:forEach items="${lotteryList}" var="lottery" >
				  <option value="${lottery.id }">${lottery.name }</option>
				</c:forEach>
				</select><a href="${ctx}/wechat/lottery/activityForm">添加奖品</a>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">设置奖品数量:</label>
			<div class="controls">
				<form:input path="lotteryNumber" htmlEscape="false" maxlength="11" class="required digits" /><span class="alert">奖品数量当没有的时候活动停止</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">兑换奖品有效天数:</label>
			<div class="controls">
				<select name="validDays" id="validDays">
					<% for(int i=1;i<31;i++) {%>
					<option value="<%=i%>" ><%=i %>天</option>
					<%} %>
				</select>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">活动是否开启:</label>
			<div class="controls">
			<input type="radio" name="status"  value="1"/>是 &nbsp;<input type="radio" name="status"  value="0"/>否
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="wechat:activity:activityConfig:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
